package com.project.controller;

import com.project.bean.StudentBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.util.List;

/**
 * @Author(王思翰)
 * @Description(类的描述)
 * @Date(创建时间) 2021/7/21 13:57
 */
@Controller
@RequestMapping("test")
public class TestController {
    @RequestMapping("show")
    public String show(HttpServletRequest request) throws UnsupportedEncodingException {
        //在request中绑定共享对象，作用范围为一次请求范围内
        request.setAttribute("name","tom");
        request.setCharacterEncoding("utf-8");
        request.setAttribute("student",new StudentBean(10,"张无忌",90));
        List<StudentBean> list=List.of(new StudentBean(10,"张无忌",90),
                new StudentBean(12,"周芷若",50),
                new StudentBean(15,"赵敏",76),
                new StudentBean(18,"小明",85));
        request.setAttribute("list",list);
        return "/html/index.html";
    }
}
